import 'dart:io';

import 'package:flutter_archive/flutter_archive.dart';
import 'package:mybase/base/tool/pprint/FFLog.dart';

class FFArchive {
  static Future<bool> zipToFile({
    required File zipFile,
    required Directory destinationDir,
  }) async {
    try {
      await ZipFile.extractToDirectory(
        zipFile: zipFile,
        destinationDir: destinationDir,
      );
      return true;
    } catch (e) {
      FFLog.error("解压出错 ${e.toString()}");
    }

    return false;
  }

  static Future<bool> zipToFile2({
    required String zipPath,
    required String destinationDir,
  }) async {
    try {
      await ZipFile.extractToDirectory(
        zipFile: File(zipPath),
        destinationDir: Directory(destinationDir),
      );
      return true;
    } catch (e) {
      FFLog.error("解压出错 ${e.toString()}");
    }

    return false;
  }
}
